package com.ll.studentservice.controller;


import com.ll.commonUtils.R;
import com.ll.studentservice.entity.EduKe;
import com.ll.studentservice.entity.EduKeInfo;
import com.ll.studentservice.service.EduKeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.time.DayOfWeek;
import java.time.LocalDate;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ll
 * @since 2020-11-27
 */
@Api(description = "课程表增删改查API") //swagger界面提示
@RestController
@RequestMapping("/studentservice/eduke")
public class EduKeController {

    @Autowired
    private EduKeService eduKeService;

    @PostMapping("addCourseInfo")
    @ApiOperation(value = "添加课程信息") //swagger界面提示
    public R addCourseInfo(@RequestBody EduKe eduKe){
        boolean save = eduKeService.save(eduKe);
        return save ? R.ok().message("添加课程信息成功") : R.error().message("添加课程信息失败");
    }

    //不能移植到SignController,因为自定义了sql语句
    //获取将要签到的课程信息(测试使用)
    @GetMapping("getlaterCourse/{classId}/{week}/{nowTime}")
    @ApiOperation(value = "获取将要签到的课程信息(测试使用)") //swagger界面提示
    public R getlaterCourseTest(@ApiParam(name = "classId", value = "班级Id", required = true)
                                @PathVariable String classId,
                                @ApiParam(name = "week", value = "星期几", required = true)
                                @PathVariable String week,
                                @ApiParam(name = "nowTime", value = "时间(格式:00:00:00)", required = true)
                                @PathVariable String nowTime){

        EduKeInfo eduKeInfo = eduKeService.findlaterCourseTest(classId, week, nowTime);

        if (StringUtils.isEmpty(eduKeInfo)){
            return R.error().message("获取课程信息失败");
        } else {
            return R.ok().data("eduKe", eduKeInfo);
        }
    }

//    //查询课程表
//    @GetMapping("findCourseSchedule")
//    @ApiOperation(value = "查询课程表") //swagger界面提示
//    public R findCourseSchedule(){
//        return null;
//    }

}

